import 'package:chat/common/routers/index.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';

class HomeMenu extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    void onMenuSelected(String value) {
      switch (value) {
        case "search":
          Get.toNamed(RouteNames.searchchat);
          break;
        case "createGroup":
          EasyLoading.showToast("创建群聊");
          break;
        case "add":
          Get.toNamed(RouteNames.addfriend);
          break;
      }
    }

    return PopupMenuButton<String>(
      onSelected: onMenuSelected,
      offset: const Offset(0, 50),
      color: Colors.white,
      shadowColor: Colors.black,
      shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
      itemBuilder:
          (BuildContext context) => const [
            PopupMenuItem(value: "search", child: Row(children: [Icon(Icons.search, color: Colors.black), SizedBox(width: 10), Text("搜索聊天")])),
            PopupMenuItem(
              value: "createGroup",
              child: Row(children: [Icon(Icons.create_outlined, color: Colors.black), SizedBox(width: 10), Text("创建群聊")]),
            ),
            PopupMenuItem(value: "add", child: Row(children: [Icon(Icons.add, color: Colors.black), SizedBox(width: 10), Text("添加好友")])),
          ],
    );
  }
}
